home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.image;
-
- import java.awt.image.ColorModel;
- import java.awt.image.ImageConsumer;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Hashtable;
-
- public abstract class ImageDecoder {
- InputStreamImageSource source;
- InputStream input;
- Thread feeder;
- protected boolean aborted;
- protected boolean finished;
- ImageConsumerQueue queue;
- ImageDecoder next;
-
- public ImageDecoder(InputStreamImageSource src, InputStream is) {
- this.source = src;
- this.input = is;
- this.feeder = Thread.currentThread();
- }
-
- public void abort() {
- this.aborted = true;
- this.source.doneDecoding(this);
- this.close();
- this.feeder.interrupt();
- }
-
- public abstract boolean catchupConsumer(InputStreamImageSource var1, ImageConsumer var2);
-
- public synchronized void close() {
- if (this.input != null) {
- try {
- this.input.close();
- } catch (IOException var1) {
- }
- }
-
- }
-
- protected void headerComplete() {
- this.feeder.setPriority(3);
- }
-
- protected int imageComplete(int status, boolean done) {
- this.source.latchConsumers(this);
- if (done) {
- this.finished = true;
- this.source.doneDecoding(this);
- }
-
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.imageComplete(status);
- }
-
- return count;
- }
-
- public boolean isConsumer(ImageConsumer ic) {
- return ImageConsumerQueue.isConsumer(this.queue, ic);
- }
-
- protected ImageConsumerQueue nextConsumer(ImageConsumerQueue cq) {
- synchronized(this.source) {
- if (this.aborted) {
- return null;
- }
-
- for(ImageConsumerQueue var4 = cq == null ? this.queue : cq.next; var4 != null; var4 = var4.next) {
- if (var4.interested) {
- return var4;
- }
- }
- }
-
- return null;
- }
-
- public abstract void produceImage() throws IOException, ImageFormatException;
-
- public void removeConsumer(ImageConsumer ic) {
- this.queue = ImageConsumerQueue.removeConsumer(this.queue, ic, false);
- if (!this.finished && this.queue == null) {
- this.abort();
- }
-
- }
-
- public void replayConsumer(ImageConsumer ic) {
- }
-
- protected int setColorModel(ColorModel model) {
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setColorModel(model);
- }
-
- return count;
- }
-
- protected int setDimensions(int w, int h) {
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setDimensions(w, h);
- }
-
- return count;
- }
-
- protected int setHints(int hints) {
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setHints(hints);
- }
-
- return count;
- }
-
- protected int setPixels(int x, int y, int w, int h, ColorModel model, byte[] pix, int off, int scansize) {
- this.source.latchConsumers(this);
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setPixels(x, y, w, h, model, pix, off, scansize);
- }
-
- return count;
- }
-
- protected int setPixels(int x, int y, int w, int h, ColorModel model, int[] pix, int off, int scansize) {
- this.source.latchConsumers(this);
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setPixels(x, y, w, h, model, pix, off, scansize);
- }
-
- return count;
- }
-
- protected int setProperties(Hashtable props) {
- ImageConsumerQueue cq = null;
-
- int count;
- for(count = 0; (cq = this.nextConsumer(cq)) != null; ++count) {
- cq.consumer.setProperties(props);
- }
-
- return count;
- }
- }
-